// Learn cc.Class:
//  - https://docs.cocos.com/creator/manual/en/scripting/class.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

cc.Class({
    extends: cc.Component,

    properties: {
        
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},
    init: function(blockType){
        if(blockType == 0){//blue
            this.node.color = new cc.Color(67, 190, 255);
        }
        else if(blockType == 1){//green
            this.node.color = new cc.Color(102,202,28);
        }
        else if(blockType == 2){//purple
            this.node.color = new cc.Color(191,57,255);
        }
        else if(blockType == 3){//red
            this.node.color = new cc.Color(226, 69, 109);
        }
        else if(blockType == 4){//yellow
            this.node.color = new cc.Color(255, 184, 12);
        }

        this.numRandom = Math.random();
        this.numSpeed = Math.random() * 7;

            
    },
    start () {

    },

    update (dt) {
        if(this.numRandom > 0.5){
           this.node.x += this.numSpeed;
        }else{
            this.node.x -= this.numSpeed;
        }
    },
});
